#include "MMGi2c.h"


short readMMG(char address)
{ 
  unsigned char* pmmg;
  unsigned short MMG;
  pmmg=(unsigned char*)(&MMG); // typecasting and defining value of pointer pmmg at beginning of MMG
  
  Wire.requestFrom(address,2); // request 2 bytes from MMG
  
  if(Wire.available()==2) // if looks at bytes available in buffer, if this is not equal 2 skips
  {
    pmmg[0]=Wire.read();
    pmmg[1]=Wire.read();   
  }
  return MMG;
}

void initialiseMMG (void)
{
  Wire.begin(); // begins I2C connection
}
